package com.ews.onlineexchange.controller;

import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.ews.onlineexchange.model.Bulletin;
import com.ews.onlineexchange.model.TradeStatus;
import com.ews.onlineexchange.service.EntityQuery;

@Model
public class CanBecomeInvalidBulletinList extends EntityQuery<Bulletin> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected List<Predicate> getRestrictions( CriteriaBuilder cb, Root<Bulletin> entity ) {
		
		List<Predicate> restrictions = super.getRestrictions( cb, entity );
		
		restrictions.add( cb.equal( entity.get( "tradeStatus" ), TradeStatus.Agreed ) );
//		restrictions.add( cb.notEqual( entity.get( "wayOfChoose" ), ChooseType.Assess ) );
		restrictions.add( cb.isFalse( entity.get( "over" ) ) );
		
		
		return restrictions;
		
	}

}
